﻿using MySql.Data.MySqlClient;

namespace Tools.Android
{
    public static class MySQLHelper
    {
        // 测试数据库连接
        public static bool TestConnection(ConnectionInfo connectionInfo, out string errorMessage)
        {
            errorMessage = string.Empty;
            try
            {
                using (MySqlConnection connection = new MySqlConnection(connectionInfo.GetConnectionString()))
                {
                    connection.Open();
                    return true;
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                return false;
            }
        }

        // 创建数据库连接
        public static MySqlConnection CreateConnection(ConnectionInfo connectionInfo)
        {
            return new MySqlConnection(connectionInfo.GetConnectionString());
        }


        
    }
}
